/**
 * @Author：ming
 * @Date：2023/9/25 10:44 PM
 * @Filename：Lc58
 */

/**
 * @author ming
 */
public class Lc58 {
    public int lengthOfLastWord(String s) {
        char[] c = s.toCharArray();
        int start = 0;
        for (int i = c.length-1; i >=0; i--) {
            if(c[i]==' '&&start==0){
                continue;
            }else if(c[i]==' '){
                break;
            }else {
                start++;
            }
        }
        return start;
    }
}
